package com.zyx.xunyilu.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import java.util.Date;

/**
 * @ClassName: CommentArticle
 * @author: zyx
 * @E-mail: 1377631190@qq.com
 * @DATE: 2019/11/14 20:30
 */
@Data
@TableName(value = "comment_article", resultMap = "com.zyx.xunyilu.mapper.CommentArticleMapper.baseMap")
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class CommentArticle {

    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 文章id
     */
    @NotNull(message = "目标id不能为空!", groups = commentToArticle.class)
    private Integer pId;

    /**
     * 内容
     */
    @NotEmpty(message = "内容不能为空!")
    private String content;

    /**
     * 追评的评论id
     */
    @NotNull(message = "追评的id不能为空!", groups = commentToComment.class)
    private Integer cId;

    /**
     * 评论的时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date    time;

    /**
     * 评论者id
     */
    private Integer personId;

    @TableField(exist = false)
    private User    user;

    @TableField(exist = false)
    private Integer count;

    // 用来做验证的分组使用,没有其他意义
    public interface commentToComment{};

    public interface commentToArticle{};
}

